home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 23 / AMIGAplus Sonderheft 23 (2000)(Falke)(DE)[!].iso / Tools / Diverse / PICTICON / SOURCE / Picticon.e < prev    next >
Text File  |  1999-11-06  |  53KB  |  1,919 lines

  1. MODULE 'exec/nodes','exec/ports','exec/types','exec/memory',
  2.        'intuition/intuition','intuition/screens','intuition/gadgetclass',
  3.        'intuition/screens','dos/dos','dos/dosextens','gadtools',
  4.        'libraries/gadtools','graphics/rastport','graphics/gfx','graphics/text',
  5.        'graphics/view','graphics/gfxbase','workbench/workbench',
  6.        'workbench/startup','wb','icon','graphics/clip','diskfont',
  7.        'libraries/diskfont','libraries/iffparse','iffparse','Asl','libraries/Asl',
  8.        'datatypes/datatypes','datatypes/datatypesclass','datatypes/pictureclass',
  9.        'utility/hooks','intuition/classes','intuition/classusr','utility/tagitem',
  10.        'libraries/locale',
  11.              'mathffp','dos/dosasl',
  12.        'datatypes','layers','keymap','devices/inputevent','mathtrans','locale'
  13. MODULE 'newicon','libraries/newicon'
  14.  
  15. MODULE    'whatis','libraries/whatisbase'
  16.  
  17. MODULE    '*doloaddt'
  18.  
  19. /* options:
  20.  
  21.   MAXIWIDTH=x       ;buffer size width
  22.   MAXIHEIGHT=x      ;buffer size height
  23.   APPICON=$         ;name of App-icon image
  24.   TEMPLATE_ICON=$   ;name of icon to modify (tooltypes, positions)
  25.   BACKGROUND_ICON=$ ;Name of background icon.
  26.   CHUNKYMODE=B      ;save icon with ReadPixels, not bitmap->image.
  27.   FORCE_EIGHT=B     ;If YES then eight planes are saved.
  28.   PIC_X_POS=x       ;Offset for image.
  29.   PIC_Y_POS=x       ;Offset for image.
  30.   PIC_X_SIZE=x      ;Real size of image (not always, but at least < than)
  31.   PIC_Y_SIZE=x      ;Real size of image.
  32.   CENTER=B          ;Center icon? Only valid with PIC_X_SIZE/PIC_Y_SIZE
  33.   SHOWSIZE_X=x      ;X pos for size coords
  34.   SHOWSIZE_Y=x      ;Y pos for size coords
  35.   LOWPRI=B          ;If= "yes" then run at priority -1
  36.   FREE_ICON_POS=B   ;Set icon to "unsnapshot"
  37.   HIGHPEN=x         ;topmost pen to use
  38.   SHOWSIZE_OUTLINE=B;If yes, then outline the size, otherwise, shadow it
  39.   SHOWSIZE_NORMAL=B ;If yes, then no shadow, no outline.
  40.   SHOWSIZE_TALL=B   ;If yes, then font is 8 high, not 6.
  41.   QUIET=B           ;If yes then surpress ALL output.
  42.   APP_X_POS=x       ;x pos of appicon
  43.   APP_Y_POS=y       ;y pos of appicon
  44.     DITHER=B                    ;if YES then do dithering
  45.  
  46. */
  47.  
  48. ENUM E_NONE,L_OK,
  49.   L_E_GENERAL,L_E_FILE,L_E_NOFILE,L_E_BADICON,L_E_NOWRITEICON,L_E_CLIP,
  50.   L_E_DATATYPE,L_E_NOPICTURE,L_E_GADGET,
  51.   L_EF_LIBRARY,L_EF_FATAL,L_EF_PUBSCREEN,L_EF_CHIPBUFFER,L_EF_VISUAL,L_EF_MENUS,
  52.   L_EF_MSGPORT,L_EF_WINDOW,L_EF_MEMORY,L_TEXTTITLE,
  53.   L_PICTURE,L_FILEOF,L_LOADING,L_SCALING,L_REMAPPING,L_SAVING,L_PERCENT,
  54.   L_TITLE,L_BODY,L_BUTTONS,L_RENDERING,L_PERCENT2,L_NUMDIRS,L_CREATINGICON,L_ENDS
  55.  
  56. ENUM MODE_CLI,MODE_WB,MODE_QUIET,MODE_APP
  57. ENUM TEXT_NORMAL,TEXT_SHADOW,TEXT_OUTLINE
  58.   OBJECT mybitmapstruct
  59.     bytesperrow:INT;rows:INT;flags:CHAR;depth:CHAR;pad:INT
  60.     plane1:LONG;plane2:LONG;plane3:LONG;plane4:LONG
  61.     plane5:LONG;plane6:LONG;plane7:LONG;plane8:LONG
  62.   ENDOBJECT
  63.  
  64. DEF dumstr[500]:STRING
  65. DEF texttype=TEXT_SHADOW,tallfont=FALSE
  66. DEF iff:PTR TO iffhandle,ierror
  67. DEF sp=NIL:PTR TO storedproperty
  68. DEF freeme=FALSE
  69. DEF curfile=1,totfile=1
  70. DEF screenfont=NIL:PTR TO textfont
  71. DEF window=NIL:PTR TO window,rast,drawinfo,fgx,fgy,fgw,fgh
  72. DEF showflag=FALSE,showx=0,showy=0,bitsizex,bitsizey,sizestr[50]:STRING
  73. DEF black,white,writecolors=2
  74. DEF posx=0,posy=0,sizex=0,sizey=0,centerflag=FALSE,posflag=FALSE
  75. DEF noappitem=FALSE
  76. DEF minimumx,minimumy
  77. DEF quietflag=FALSE,goodload
  78. DEF requestsizex,requestsizey,highestcolor
  79. DEF k[15]:LIST
  80. DEF redt[256]:LIST,grnt[256]:LIST,blut[256]:LIST
  81. DEF ditz,dang,dumb,body
  82. DEF osversion,quitter,newicon=FALSE
  83. DEF abort
  84. DEF aspectx=1,aspecty=1,useaspect=TRUE,addicon=FALSE,addiconoverwrite=FALSE
  85. DEF radian,pointfive
  86. DEF catalog,sl[500]:LIST
  87. DEF iconianheader[80]:STRING
  88. DEF scratch,ret,dummy
  89. DEF appimagedata,diskobj=NIL:PTR TO diskobject,newdiskobj=NIL:PTR TO newdiskobject
  90. DEF progname[500]:STRING,sleepername[500]:STRING,templatename[500]:STRING
  91. DEF backname[500]:STRING
  92. DEF gaugestr[100]:STRING
  93. DEF toolobject=NIL:PTR TO diskobject
  94. DEF stretch=FALSE
  95. DEF greyscale=0,quant=256
  96. DEF usewhatis=TRUE
  97. DEF chunkyflag=FALSE,force8=FALSE,first4=-1
  98. DEF maxiwidth=128,maxiheight=100,maxiw=127,maxih=99
  99. DEF filename[500]:STRING
  100. DEF mode=MODE_CLI
  101. DEF scr=NIL:PTR TO screen,viewport:PTR TO viewport
  102. DEF bitmap:PTR TO bitmap,depth,colormap=0,newcolormap=0,cmbuf=0
  103. DEF currast=NIL:PTR TO rastport,curbitmap=NIL:PTR TO bitmap
  104. DEF appname[500]:STRING
  105. DEF visual=NIL,winx=-1,winy=-1
  106. DEF oldpx=-1
  107. DEF appx=-1,appy=-1
  108. DEF dither=TRUE
  109. DEF twopass=FALSE
  110. DEF rawdata=0
  111. DEF div1=3,div2=0,div3=3,div4=1,rem1=8,rem2=1,rem3=8,rem4=4
  112. DEF thres=2,ignore=16,lim=255,typ=0
  113. DEF iinfo=0:PTR TO imageinfo
  114. DEF stacked[750]:LIST
  115. DEF renderham=FALSE
  116. DEF hamthres=-1
  117. DEF    hambase=FALSE
  118. DEF discard=FALSE
  119. PROC main()
  120.     NEW iinfo
  121.   openlibs()
  122.   radian:=sp_div_tf_tf_f(10000,572958)
  123.   pointfive:=sp_div_tf_tf_f(10,5)
  124.   StrCopy(iconianheader,'Picticon 1.1',ALL)
  125.   loadwinpos()
  126.   handwb()
  127.   savewinpos()
  128.   leave(0)
  129. ENDPROC
  130.  
  131. PROC setraw(x,y,r,g,b)
  132.   IF rawdata
  133.     PutLong(rawdata+(limit(x,0,maxiwidth)*12)+(limit(y,0,1)*12*maxiwidth),r)
  134.     PutLong(rawdata+(limit(x,0,maxiwidth)*12)+4+(limit(y,0,1)*12*maxiwidth),g)
  135.     PutLong(rawdata+(limit(x,0,maxiwidth)*12)+8+(limit(y,0,1)*12*maxiwidth),b)
  136.   ENDIF
  137. ENDPROC
  138.  
  139. PROC rawred(x,y)
  140.   RETURN Long(rawdata+(x*12)+(y*12*maxiwidth))
  141. ENDPROC
  142.  
  143. PROC rawgrn(x,y)
  144.   RETURN Long(rawdata+4+(x*12)+(y*12*maxiwidth))
  145. ENDPROC
  146.  
  147. PROC rawblu(x,y)
  148.   RETURN Long(rawdata+8+(x*12)+(y*12*maxiwidth))
  149. ENDPROC
  150.  
  151. PROC processicon() HANDLE
  152.   DEF gadget:PTR TO gadget
  153.   DEF backobj=NIL:PTR TO diskobject
  154.   DEF screenattr:PTR TO textattr,sfonth=8
  155.   DEF heystring[500]:STRING,file[500]:STRING
  156.     DEF whaticon[500]:STRING
  157.   DEF iiii,tttt,oldshowx,loo,gc1,gc2
  158.     DEF inw,inh,lock
  159.     DEF imsg:PTR TO intuimessage
  160.     DEF whatobj=NIL:PTR TO diskobject
  161.     DEF newwhatobj=NIL:PTR TO newdiskobject
  162.  
  163.   oldshowx:=showx
  164.   window:=NIL
  165.   IF StrLen(filename)<1 THEN Raise(E_NONE)
  166.   IF ((scr:=LockPubScreen('Workbench'))=0) THEN Raise(L_EF_PUBSCREEN)
  167.   visual:=GetVisualInfoA(scr,NIL)
  168.   viewport:=scr.viewport
  169.   colormap:=viewport.colormap
  170.   bitmap:=scr.bitmap
  171.   depth:=bitmap.depth
  172.     IF (newicon)
  173.         newcolormap:=GetColorMap(256)
  174.         cmbuf:=New(32)
  175.         FOR loo:=0 TO 255
  176.             gc1:=loo AND (Shl(1,depth)-1)
  177.             GetRGB32(colormap,gc1,1,cmbuf)
  178.             SetRGB32CM(newcolormap,loo,Long(cmbuf),Long(cmbuf+4),Long(cmbuf+8))            
  179.         ENDFOR
  180.         colormap:=newcolormap
  181.         Dispose(cmbuf)
  182.     ENDIF
  183.   IF (curbitmap:=myallocbitmap(maxiwidth,maxiheight,8,BMF_CLEAR OR BMF_STANDARD,NIL))=NIL THEN Raise(L_EF_CHIPBUFFER)
  184.  
  185.   IF (currast:=New(SIZEOF rastport))=NIL THEN Raise(L_EF_FATAL)
  186.   InitRastPort(currast);currast.bitmap:=curbitmap
  187.  
  188.   screenattr:=scr.font
  189.   sfonth:=screenattr.ysize
  190.  
  191.   IF ((mode<>MODE_QUIET) AND (mode<>MODE_CLI))
  192.         inw:=bigger(300,12*StrLen(FilePart(filename)))
  193.         inh:=sfonth*3+20-(((totfile<-1) OR (totfile>1))*(sfonth+4))
  194.     IF winx=-1 THEN winx:=(((scr.width-300)/2))
  195.     IF winy=-1 THEN winy:=(((scr.height-(sfonth*2+16))/2))
  196.     window:=OpenWindowTagList(0,[WA_LEFT,winx,
  197.       WA_TOP,winy,
  198.       WA_INNERWIDTH,inw,
  199.       WA_INNERHEIGHT,inh,
  200.       WA_FLAGS,WFLG_DRAGBAR OR WFLG_DEPTHGADGET OR WFLG_CLOSEGADGET,
  201.             WA_IDCMP,IDCMP_CLOSEWINDOW,
  202.       WA_TITLE,sl[L_TEXTTITLE],
  203.       WA_CUSTOMSCREEN,scr,
  204.       WA_AUTOADJUST,TRUE,
  205.       NIL,NIL])
  206.     rast:=window.rport
  207.     screenfont:=OpenFont(scr.font)
  208.     IF screenfont THEN SetFont(rast,screenfont)
  209.     fgx:=4+window.borderleft
  210.     fgw:=window.width-(8+window.borderleft+window.borderright)
  211.     fgh:=window.height-(window.bordertop+4+window.borderbottom)-(sfonth*2)-8+(((totfile<-1) OR (totfile>1))*(sfonth+4))
  212.     fgy:=window.height-(sfonth*2)-18
  213.  
  214.  
  215.         SetAPen(rast,2)
  216.         shadowtext(rast,fgx,fgy+6+fgh+screenfont.baseline,'0%',2)
  217.         shadowtext(rast,fgx+fgw-TextLength(rast,'100%',4),fgy+fgh+6+screenfont.baseline,'100%',4)
  218.         shadowtext(rast,fgx+(fgw/2)-(TextLength(rast,'50%',3)/2),fgy+fgh+6+screenfont.baseline,'50%',3)
  219.         shadowtext(rast,fgx+(fgw/4)-(TextLength(rast,'25%',3)/2),fgy+fgh+6+screenfont.baseline,'25%',3)
  220.         shadowtext(rast,fgx+(fgw*3/4)-(TextLength(rast,'75%',3)/2),fgy+fgh+6+screenfont.baseline,'75%',3)
  221.  
  222.     StringF(heystring,sl[L_PICTURE],FilePart(filename))
  223.     SetAPen(rast,1)
  224.     Move(rast,fgx+(fgw/2)-(TextLength(rast,heystring,StrLen(heystring))/2),window.bordertop+3+screenfont.baseline)
  225.     Text(ras